import request from "@/utils/request";

// 查询生产退料单基础列表
export function listBack(query) {
  return request({
    url: "/mes/pro/back/list",
    method: "get",
    params: query,
  });
}

// 查询生产退料单基础详细
export function getBack(id) {
  return request({
    url: "/mes/pro/back/" + id,
    method: "get",
  });
}

// 新增生产退料单基础
export function addBack(data) {
  return request({
    url: "/mes/pro/back",
    method: "post",
    data: data,
  });
}

// 修改生产退料单基础
export function updateBack(data) {
  return request({
    url: "/mes/pro/back",
    method: "put",
    data: data,
  });
}

// 删除生产退料单基础
export function delBack(id) {
  return request({
    url: "/mes/pro/back/" + id,
    method: "delete",
  });
}

// 新增生产退料单基础详情
export function addBatchBackInfo(data) {
  return request({
    url: "/mes/pro/back/addBatch",
    method: "post",
    data: data,
  });
}

// 更新生产退料单基础详情
export function updateBatchBackInfo(data) {
  return request({
    url: "/mes/pro/back/updateBatch",
    method: "post",
    data: data,
  });
}

// 生成生产退料单审批流
export function getBackApprovalProcess(id) {
  return request({
    url: "/mes/pro/approval/back/create/" + id,
    method: "get",
  });
}
export function getBackCreateProcess(id) {
  return request({
    url: "/mes/workflow/PrBack/create/" + id,
    method: "get",
  });
}

// 查看审批流信息
export function getApprovalList(id) {
  return request({
    url: "/mes/pro/approval/back/list/" + id,
    method: "get",
  });
}
export function getPrBackList(id) {
  return request({
    url: "/mes/workflow/PrBack/list/" + id,
    method: "get",
  });
}

// 查看仓库信息
export function getWareHouseList(query) {
  return request({
    url: "/mes/pro/back/warehouse/list",
    method: "get",
    params: query,
  });
}

// 查看退料原因信息
export function getBackResonList() {
  return request({
    url: "/mes/pro/back/dict/back/list",
    method: "get",
  });
}

// 生成领料单
export function backProcess(data) {
  return request({
    url: "/mes/pro/back/add/warehouse",
    method: "get",
    params: data,
  });
}
// 审批流程
export function submitPrBack(data) {
  return request({
    url: "/mes/workflow/PrBack/submit",
    method: "post",
    data: data,
  });
}

// 生成质检单
export function backGenerate(backId) {
  return request({
    url: "/mes/pro/back/detail/generateIqcInspection/" + backId,
    method: "get",
  });
}

export function getSequenceCodeByWorkorderCode(id) {
  return request({
    url: "/mes/pro/back/getSequenceCodeByWorkorderCode/" + id,
    method: "get",
  });
}

/* 2024-11-18 djj 查询可以退的物料列表 */
export function getItemList(id) {
  return request({
    url: "/mes/pro/back/getItemList/" + id,
    method: "get",
  });
}
/* 2024-11-21 djj PCBA扫码获取物料信息 */
export function getListByScanning(query) {
  return request({
    url: "/mes/pro/back/detail/listByScanning",
    method: "get",
    params: query,
  });
}

//add begin by zyj 2024/11/23

export function generateStockInOrder(query) {
  return request({
    url: "/mes/pro/back/generateProductRecpt",
    method: "get",
    params: query,
  });
}
//add end by zyj 2024/11/23

export function saveToErp(backCode) {
  return request({
    url: "/mes/k3cloud/api/productionBack/saveToerp/" + backCode,
    method: "get",
  });
}
